#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+7;
using ld=long double;
int d[N],v[N],a[N];
struct Node{
	int l,r;
	bool operator< (const Node &b) const{
		return r<b.r;
	}
} b[N];
ld p[N];
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T;
	scanf("%lld",&T);
	while (T--){
		int n,m,len,k,ans=0;
		scanf("%lld%lld%lld%lld",&n,&m,&len,&k);
		for (int i=1;i<=n;++i)
			scanf("%lld%lld%lld",d+i,v+i,a+i);
		for (int i=1;i<=m;++i)
			scanf("%Lf",p+i);
        p[m+1]=1e18;
		for (int i=1;i<=n;++i){
            if (d[i]>p[m]) continue;
			int pos;
			if (a[i]>=0) pos=m;
			else pos=lower_bound(p+1,p+m+1,(ld)(1.0)*d[i])-p;
			if (v[i]*v[i]+2*a[i]*(p[pos]-d[i])>k*k) ++ans;
			else continue;
			ld x=(k*k-v[i]*v[i])/2.0/a[i]+d[i];
			int l,r;
			if (a[i]>=0) b[ans].l=lower_bound(p+1,p+m+1,max(x,(ld)1.0*d[i]))-p,b[ans].r=m;
			else b[ans].r=lower_bound(p+1,p+m+1,x)-p-1,b[ans].l=pos;
		}
		printf("%lld ",ans),n=ans,ans=0;
		sort(b+1,b+n+1);
		int pos=0;
		for (int i=1;i<=n;++i)
            if (b[i].l>pos) ++ans,pos=b[i].r;
		printf("%lld\n",m-ans);
	}
	return 0;
}
